package daoBDDImpl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import utils.HibernateUtil;
import bean.Inscription;
import bean.Manifestation;
import bean.Personne;
import dao.InscriptionDao;

public class InscriptionDaoBDDImpl extends HibernateDaoSupport implements InscriptionDao {

	public InscriptionDaoBDDImpl(){
		super();
		setSessionFactory(HibernateUtil.getSessionFactory());
	}
		
	@Override
	public Inscription getInscription(long id) {
		return getHibernateTemplate().get(Inscription.class, id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Inscription> getInscriptionByManifestation(	Manifestation manifestation) {
		return getHibernateTemplate().findByNamedQueryAndNamedParam("getInscriptionByManifestation","manifestation",manifestation);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Inscription> getInscriptionByPersonne(Personne personne) {
		return getHibernateTemplate().findByNamedQueryAndNamedParam("getInscriptionByPersonne","personne",personne);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Inscription> getAll(){
		return getHibernateTemplate().findByNamedQuery("getAllInscription");
	}
	@Override
	public void setInscription(Inscription inscription) {
		getHibernateTemplate().save(inscription);
	}

	@Override
	public void delInscription(Inscription inscription) {
		getHibernateTemplate().delete(inscription);
	}
	
	

}
